﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace AgileShare.Framework.Library.Helpers
{
    public class SPNotification
    {
        /// <summary>
        /// 右上角弹出消息，自动消失
        /// </summary>
        /// <param name="page"></param>
        /// <param name="text"></param>
        public static void AddSharePointNotification(Page page, string text)
        {         
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine("ExecuteOrDelayUntilScriptLoaded(ShowNotification, \"sp.js\");");
            stringBuilder.AppendLine("function ShowNotification()");
            stringBuilder.AppendLine("{");
            stringBuilder.AppendLine(string.Format("SP.UI.Notify.addNotification(\"{0}\");", text));
            stringBuilder.AppendLine("}");
            page.ClientScript.RegisterClientScriptBlock(typeof(Page), "alert", stringBuilder.ToString(),true);
        }
    }
}
